package com.java.Map.Hashtable;

import java.io.*;
import java.util.Properties;

public class PropertiesAPI {
    public static void main(String[] args) throws IOException {
        String path = "集合\\com\\java\\Map\\Hashtable\\properties.properties";
        
        // store：将集合内的数据以键值对的形式写到配置文件中
        Properties properties1 = new Properties();
        properties1.put("protocol", "http");
        properties1.put("ip", "localhost");
        properties1.put("port", "8080");
        properties1.store(new BufferedWriter(new FileWriter(path)), "配置文件");
        
        // load：将配置文件中的数据以键值对的形式读取到集合中
        Properties properties2 = new Properties();
        properties2.load(new BufferedReader(new FileReader(path)));
        System.out.println(properties2); // {port=8080, protocol=http, ip=localhost}
    }
}
